<!--
 * @Author: MarioGo
 * @Date: 2021-11-10 16:41:41
 * @LastEditTime: 2021-11-11 13:49:47
 * @LastEditors: MarioGo
 * @Description: 文件描述
 * @FilePath: /zheye/src/views/ColumnDetail.vue
 * 可以输入预定的版权声明、个性签名、空行等
-->
<template>
  <div class="column-detail-page w-75 mx-auto">
    <div class="column-info row mb-4 border-bottom pb-4 align-items-center" v-if="column">
      <div class="col-3 text-center">
        <img :src="column.avatar" :alt="column.title" class="rounded-circle border w-100" />
      </div>
      <div class="col-9">
        <h4>{{ column.title }}</h4>
        <p class="text-muted">{{ column.description }}</p>
      </div>
    </div>
    <post-list :list="list"></post-list>
    <div style="text-align: center">
      <button
        class="btn btn-outline-primary mt-2 mb-5 mx-auto btn-block w-25"
        @click="loadMorePage"
        v-if="!isLastPage"
      >
        加载更多
      </button>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { useRoute } from 'vue-router';
import { testData, testPosts } from '../testData';
import PostList from '../components/PostList.vue';
export default defineComponent({
  name: 'columnDetail',
  components: {
    PostList,
  },
  setup() {
    const route = useRoute();
    //获取页面id参数
    const currentId = +route.params.id;
    const column = testData.find((i) => currentId === i.id);
    const list = testPosts.filter((p) => p.id);

    const loadMorePage = () => {
      console.log('loadMorePage :>> ');
    };
    const isLastPage = false;
    return {
      currentId,
      column,
      list,
      loadMorePage,
      isLastPage,
    };
  },
});
</script>

<style scoped></style>
